<template>
    <n-dynamic-tags v-model:value="propertiesTag" @update:value="onUpdate" type="info">
    </n-dynamic-tags>
</template>

<script lang='ts'>

import {computed, reactive,ref} from 'vue';
import { NDynamicTags ,useMessage} from 'naive-ui';

export default{

components:{
    NDynamicTags,
},

props:{
    row:Object,
    selectedValue:String,
    propertiesState:Boolean,
},

setup(props:any){
    const change=ref(false);
    const message=useMessage();
    let propertiesTag=computed(()=>{
        if(change.value)
        {
            change.value=!change.value;
        }
        let list=JSON.parse(localStorage.getItem('goodsClassificationList'));
        let strlist=props.selectedValue.split(" ");
        let propertiesTags='';
        if(props.propertiesState)
            propertiesTags='dynamicPropertiesTags';
        else
            propertiesTags='staticPropertiesTags';
        let tags=list[strlist[0]].children[strlist[1]].children[strlist[2]][propertiesTags][props.row.propertiesName];
        return tags;
    })

    const onUpdate=(value:any)=>{
        let list=JSON.parse(localStorage.getItem('goodsClassificationList'));
        let strlist=props.selectedValue.split(" ");
        let propertiesTags='';
        if(props.propertiesState)
            propertiesTags='dynamicPropertiesTags';
        else
            propertiesTags='staticPropertiesTags';
        list[strlist[0]].children[strlist[1]].children[strlist[2]][propertiesTags][props.row.propertiesName]=value;
        propertiesTag=value;
        localStorage.setItem("goodsClassificationList",JSON.stringify(list));
        message.success('操作成功');
        change.value=true;
    }

    return {
        propertiesTag,
        onUpdate,
    }
}
    
}

</script>